app.controller('firstLargeExamineCtrl', function($element, $scope, $state, rest, user, uploadConf, tipService, $window, $rootScope, decoJavaUrlLsf) {
    $scope.idstring = angular.copy($scope.ngDialogData, {});
    var token = $window.localStorage.getItem("token");
    $scope.queryParams = {

    }
    rest.decoJava({
        type: "post",
        url: "/tenancy-sys/admin/house/skip",
        data: {
            houseIds: $scope.idstring._idstring,
        },
        beforeSend: function(request) {
            request.setRequestHeader("token", token);
        },
        success: function(res) {
            if (res.code == "0000") {
                $scope.queryParams.landlordName = res.result.landlordName;
                $scope.queryParams.landlordMobile = res.result.landlordMobile;
                $scope.queryParams.size = res.result.size;
                $scope.$apply();
            } else {
                $scope.closeThisDialog();
                tipService.show("body", {
                    message: res.message,
                    notice: "danger"
                }, 3);
            }
        }
    })

    $scope.exportData = function() {

        rest.decoJava({
            type: "post",
            url: "/tenancy-sys/admin/house/updateHouseAssigneds",
            data: {
                houseIds: $scope.idstring._idstring,
            },
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success: function(res) {
                $scope.closeThisDialog();
                $scope.$apply();
            }
        })
    }

    $("#suggest").on("input propertychange", function() {
        var $this = $(this),
            _val = $this.val(),
            count = "";
        if (_val.length > 200) {
            $this.val(_val.substring(0, 200));
        }
        count = 200 - $this.val().length;
        $("#text-count").text(count);
    });

    //回退补件
    $scope.fallback = function() {
        $scope.queryParams.houseIds = $scope.idstring._idstring;
        if (!$scope.queryParams.remark) {
            tipService.show("body", {
                message: "审核意见未填写",
                notice: "danger"
            }, 3);
            return;
        }
        rest.decoJava({
            type: "post",
            url: "/tenancy-sys/admin/house/houseSupplementProcess",
            data: $scope.queryParams,
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success: function(data) {
                if (data.code == 0000) {
                    tipService.show("body", {
                        message: data.message,
                    }, 3);
                    $scope.closeThisDialog();
                } else {
                    tipService.show("body", {
                        message: data.message,
                        notice: "danger"
                    }, 3);
                    return;
                }
            }
        });
    }

    //通过
    $scope.passThrough = function() {
        $scope.queryParams.houseIds = $scope.idstring._idstring;
        if (!$scope.queryParams.remark) {
            tipService.show("body", {
                message: "审核意见未填写",
                notice: "danger"
            }, 3);
            return;
        }
        rest.decoJava({
            type: "post",
            url: "/tenancy-sys/admin/house/updateHouseProcess",
            data: $scope.queryParams,
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success: function(data) {
                if (data.code == 0000) {
                    tipService.show("body", {
                        message: data.message,
                    }, 3);
                    $scope.closeThisDialog();
                } else {
                    tipService.show("body", {
                        message: data.message,
                        notice: "danger"
                    }, 3);
                    return;
                }
            }
        });
    }

    //拒绝
    $scope.refuse = function() {
        $scope.queryParams.houseIds = $scope.idstring._idstring;
        if (!$scope.queryParams.remark) {
            tipService.show("body", {
                message: "审核意见未填写",
                notice: "danger"
            }, 3);
            return;
        }
        rest.decoJava({
            type: "post",
            url: "/tenancy-sys/admin/house/updateHouseRepulse",
            data: $scope.queryParams,
            beforeSend: function(request) {
                request.setRequestHeader("token", token);
            },
            success: function(data) {
                if (data.code == 0000) {
                    tipService.show("body", {
                        message: data.message,
                    }, 3);
                    $scope.closeThisDialog();
                } else {
                    tipService.show("body", {
                        message: data.message,
                        notice: "danger"
                    }, 3);
                    return;
                }
            }
        });
    }

    $scope.hideBtn = function() {
        $scope.closeThisDialog();
    }

});